<?php
namespace app\index\controller;

use app\common\controller\IndexBase;
use think\Session;
use think\Db;

/**
* 
*/
class Goods extends IndexBase
{
	
	/*public function index(){

        $data = Db::name("Goods")->where("status",1)->select();
        
        $this->titleName = "商城";
        $this->assign('data',$data);
        print_r($data);
	}*/

	public function detail(){
        $userinfo = Session::get('userInfo');
        $id = input('param.id');
        if( empty($id) ){
            $this->error("此商品已下架");
        }
        $data = Db::name('goods')->where("id",$id)->find();
        if( empty($data) ){
            $this->error("此商品已下架");
        }
        $is_shop = 0;
        if($userinfo){
            $is_shop = get_user_is_shop($userinfo['id']);
        }
        if($is_shop == 0 && $data['type'] == 1){
            $data['price'] = $data['first_price'];
        }elseif($data['type'] == 2){
            $data['price'] = $data['cz_price'];
        }elseif($data['type'] == 3){
            $data['price'] = $data['dl_price'];
        }

        $this->titleName = "商品详情";
        $this->assign('data',$data);
        return $this->fetch();
    }
}